<template>
  <div class="container">
    <el-dialog
      title="题目审核"
      :visible="dialogVisible"
      width="30%"
      :before-close="btnCancel"
    >
      <el-form ref="form" :model="form" :rules="rules">
        <el-form-item>
          <el-radio-group v-model="form.chkState">
            <el-radio label="1">通过</el-radio>
            <el-radio label="2">拒绝</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item prop="chkRemarks">
          <el-input type="textarea" v-model="form.chkRemarks"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="btnCancel">取消</el-button>
        <el-button type="primary" @click="handelConfirm(form)">确认</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'QuestionCheck',
  data () {
    return {
      form: {
        chkState: '1',
        chkRemarks: ''
      },
      rules: {
        chkRemarks: [
          { required: true, message: '请填写审核意见', trigger: 'blur' }
        ]
      }
    }
  },
  props: {
    dialogVisible: {
      type: Boolean,
      required: true
    }
  },
  methods: {
    // 关闭和取消
    btnCancel () {
      this.$emit('update:dialogVisible', false)
    },
    // 确定
    async handelConfirm (form) {
      await this.$refs.form.validate()
      this.$emit('check', { chkState: +this.form.chkState, chkRemarks: this.form.chkRemarks })
      this.$message({
        message: '操作成功',
        type: 'success'
      })
      this.btnCancel()
    }

  }
}
</script>

<style scoped lang='less'></style>
